Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(assets): $refs under functionOptions cannot be relative to the document #1305

Merged
merged 1 commit into from
Aug 19, 2020

Conversation

P0lip
Copy link
Contributor

@P0lip P0lip commented Aug 19, 2020

Fixes the issue with oas2/oas3-schema rules in Studio.

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

Additional context

Why is it broken?
Some time ago we switched from dereferencing to bundling strategy when resolving $refs in rulesets during the Spectral offline assets generation.
This had one unintended side effect - as of that change all $refs are scoped relatively to the whole document.
This causes troubles, since in certain cases such has we pass a portion of the entire ruleset.
Having rewritten inline $refs inside of functionOptions is not really desired, because we always pass a given portion of the ruleset, therefore the $refs won't be resolvable, and eventually Ajv will refuse to validate the document.

  MissingRefError {
      message: "can't resolve reference #/rules/oas3-schema/then/functionOptions/schema/definitions/Info from id https://spec.openapis.org/oas/3.0/schema/2019-04-02#",
      missingRef: 'https://spec.openapis.org/oas/3.0/schema/2019-04-02#/rules/oas3-schema/then/functionOptions/schema/definitions/Info',
      missingSchema: 'https://spec.openapis.org/oas/3.0/schema/2019-04-02'
    }

The following PR makes sure we bundle only external $refs, while all inline $refs are kept untouched.

@P0lip P0lip added the chore label Aug 19, 2020
@P0lip P0lip self-assigned this Aug 19, 2020
@marbemac
Copy link
Contributor

If you have not already, could you yalc into Studio and give it a thorough testing?

@P0lip
Copy link
Contributor Author

P0lip commented Aug 19, 2020

If you have not already, could you yalc into Studio and give it a thorough testing?

I've already yalced it, but my testing was rather brief and focused primarily on the oas2/oas3-schema rules.
image

@P0lip P0lip merged commit 627a24d into develop Aug 19, 2020
@P0lip P0lip deleted the build/generated-assets-refs branch August 19, 2020 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants